package com.example.communitypro.service.impl;

import com.example.communitypro.mapper.SystemMapper;
import com.example.communitypro.pojo.Post;
import com.example.communitypro.pojo.SystemSetting;
import com.example.communitypro.service.SystemServiceImpl;
import com.example.communitypro.util.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;

@Service
public class SystemServiceImplImpl implements SystemServiceImpl {

    @Autowired(required = false)
    private SystemMapper systemMapper;

    @Override
    public SystemSetting find() {
            SystemSetting systemSetting = systemMapper.find();
            if(systemSetting!=null)
            {
                return systemSetting;
            }else {
                return new SystemSetting();
            }
    }

    @Override
    public String updateSystem(SystemSetting systemSetting){
        try {
            if(systemMapper.updateSystem(systemSetting)>0)
            {
                return "1";
            }
            else{
                return "0";
            }
        } catch (Exception e){
            System.err.println(e);
            return "0";
        }
    }
}
